<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://unpkg.com/vue"></script>
    <script>
        window.onload =function(){
            var app4 = new Vue({
                el: '#app-4',
                methods:{
                    addpeoples:function(){
                        var x={name:this.username,age:this.age,time:new Date()};
                        this.peoples.push(x);
                    },
                    removeall:function(){
                        this.peoples=[];
                    },
                    removeasd:function(){
                        this.username=null;
                        this.age=null;
                    },
                    removeTodo: function (index) {
                        this.peoples.splice(index, 1);
                    }
                },
                data: {
                    username:'',
                    age:'',
                    asd:'小黑胖',
                    peoples:[
                        {name:'ad',age:10,time:new Date()},
                        {name:'qwe',age:11,time:new Date()}
                    ]

                },
                filters:{
                    hhmmss:function(v){
                        return(v.getHours()+':'+ v.getMinutes()+':'+ v.getSeconds())

                    },
                    capitalize: function (value) {
                        if (!value) return ''
                        value = value.toString()
                        return value.charAt(0).toUpperCase() + value.slice(1)
                    }
                }

            })
        }
    </script>
</head>
<body>
<div id="app-4">
    <a style="">{{asd}}</a><br>
    <a>姓名：</a>
    <input v-model="username"><br>
    <a>年龄：</a>
    <input v-model="age"><br>
    <button v-on:click="addpeoples">添加</button>
    <button v-on:click="removeasd">重置</button>
    <button v-on:click="removeall">全部删除</button>
    <table border="1">
        <tr>
            <th>序号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>添加时间</th>
            <th>操作</th>
        </tr>
        <tr  v-for="(people,index) in peoples">
            <td>{{index+1}}</td>
            <td>{{people.name|capitalize}}</td>
            <td>{{people.age}}</td>
            <td>{{people.time|hhmmss}}</td>
            <td><button v-on:click="removeTodo(index)">删除</button></td>
        </tr>
    </table>
</div>
</body>
</html>